function throttle(fn, time) {
  let _arguments = arguments
  let canRun = true
  return function() {
    if (!canRun) return
    canRun = false
    setTimeout(() => {
      fn.call(this, _arguments)
      canRun = true
    }, time)
  }
}
function debounce(fn, time) {
  let _arguments = arguments
  let timeout = null
  return function() {
    if (timeout) {
      clearTimeout(timeout)
    }
    timeout = setTimeout(() => {
      fn.call(this, _arguments)
    }, time)
  }
}
export { throttle, debounce }
